//
//  UserViewController.m
//  FoodCorner
//
//  Created by Summer on 16/2/26.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "UserViewController.h"
#import "UpView.h"
#import "DownView.h"
#import "UsertoolBarBut.h"
#import "setUpTableViewController.h"
#import "CollectionTableViewController.h"
#import "OrderTableViewController.h"
#import "DiscountTableViewController.h"
#import "IntergralTableViewController.h"

@interface UserViewController ()
@property (nonatomic ,strong)UpView *upView;
@property (nonatomic ,strong)DownView *downView;
@end

@implementation UserViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    //将两个view添加到视图控制器
    self.upView= [[UpView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height*0.4)];
    self.downView = [[DownView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.upView.frame), self.view.frame.size.width, self.view.frame.size.height *0.6)];
    
    
    [self.view addSubview:_upView];
    [self.view addSubview:_downView];
    
    //标题按钮
    self.navigationItem.title = @"我";
    //右边按钮图标
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"设置" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction)];
    
    //左边按钮图标
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"tabbar_profile@2x"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonAction)];
    
    
    //注册一个通知  当点击收藏、订单、优惠、积分按钮的时候实现页面的跳转
     //跳转到收藏
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationOne) name:@"cllectionController" object:nil];
     //跳转到订单
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationTwo) name:@"orderController" object:nil];
     //跳转到优惠
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationThree) name:@"discountController" object:nil];
     //跳转到积分
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationFour) name:@"intergralController" object:nil];
    
    
   
    
}
//通知方法
- (void)notificationOne  
{
    CollectionTableViewController *collectionVC = [[CollectionTableViewController alloc] init];
    [self.navigationController pushViewController:collectionVC animated:YES];
//    [self.navigationController presentViewController:collectionVC animated:YES completion:nil];
    
}
- (void)notificationTwo

{
    OrderTableViewController *orderVC = [[OrderTableViewController alloc] init];
    [self.navigationController pushViewController:orderVC animated:YES];
}
- (void)notificationThree

{
    DiscountTableViewController *discountVC = [[DiscountTableViewController alloc] init];
    [self.navigationController pushViewController:discountVC animated:YES];
}
- (void)notificationFour

{
    IntergralTableViewController *intergralVC = [[IntergralTableViewController alloc] init];
    [self.navigationController pushViewController:intergralVC animated:YES];
}


    

    
    
    
    
    
    
 //左边按钮
- (void)leftBarButtonAction{
    
 
    
}

//右边设置按钮的点击事件方法
- (void)rightBarButtonAction{
    
    setUpTableViewController *setTVC = [[setUpTableViewController alloc]init];
    [self.navigationController pushViewController:setTVC animated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
